package com.waypolice.manager.controller;

import com.waypolice.manager.service.ArchiveUseCountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 描述:
 *
 * @author zyp
 * @description 档案利用统计情况action
 * @create 2019-04-01 9:10
 */
@Controller
@Api(value = "档案利用统计控制层", description = "档案利用统计")
@RequestMapping(value="/pcwindow")
public class ArchiveUseCountAction {

    private static final Logger logger = LoggerFactory.getLogger(ArchiveUseCountAction.class);

    @Autowired
    private ArchiveUseCountService archiveUseCountService;

    /**
     * @author:zyp
     * @description 跳转到利用统计的页面
     * @date: 2019/4/1 9:13
     * @return 
     */
    @ApiOperation(value = "跳转到利用统计的页面")
    @RequestMapping(value = "/toUseCount")
    public String toUseCount( HttpServletResponse response,
                                  HttpServletRequest request) {
        return "/countManager/useCount";
    }

    /**
     * @author:zyp
     * @description 获取利用统计table
     * @date: 2019/4/1 11:45
     * @return 
     */
    @ApiOperation(value = "获取利用统计table")
    @RequestMapping(value = "/getUseCountTable")
    @ResponseBody
    public Object getUseCountTable(@RequestParam(required = false, defaultValue = "0", value = "offset") int offset,
                                   @RequestParam(required = false, defaultValue = "10", value = "limit") int limit,
                                   @RequestParam(required = false, defaultValue = "", value = "search") String search,
                                   @RequestParam(required = false, value = "sort") String sort,
                                   @RequestParam(required = false, value = "order") String order,
                                   HttpServletRequest request){
        String firstDate = request.getParameter("firstDate");
        String lastDate = request.getParameter("lastDate");
        Object result = archiveUseCountService.getUseCountTable(offset, limit,firstDate,lastDate);
        return result;
    }

    /**
     * @author:zyp
     * @description 获取利用统计占比数据 进行饼状图输出
     * @date: 2019/4/2 11:03
     * @return
     */
    @ApiOperation(value = "获取利用统计占比数据 进行饼状图输出")
    @RequestMapping(value = "/getUseCountPropor")
    @ResponseBody
    public Object getUseCountPropor(HttpServletRequest request){
        String firstDate = request.getParameter("firstDate");
        String lastDate = request.getParameter("lastDate");
        Object result = archiveUseCountService.getUseCountPropor(firstDate,lastDate);
        return result;
    }

}